<template lang="html">
  <div class="member_welfare_product" @click="itemClick">
    <img :src="item.product_image" alt="">
    <p class="product_name">{{item.product_short_name}}</p>
    <p class="coupon" v-if="item.product_discount">{{item.product_discount}}</p>
    <p class="no_coupon" v-else></p>
    <p class="price">￥{{item.product_unit_price}}/<span>赚{{item.discount}}</span></p>
  </div>
</template>

<script>
export default {
  props: {
    item: Object
  },
  data () {
    return {
    }
  },
  created () {
  },
  methods: {
    itemClick () {
      let e = this.item
      let url = '/main/shopDetails'
      this.$router.push({ path: url,
        query: {
          pid: e.id,
          item_id: e.default_item_id,
          activity_id: e.activity_id ? e.activity_id : 0,
          activity_name: e.activity_name ? e.activity_name : ''
        }
      })
    },
    goBuy () {
      this.$toast.loading({
        mask: true,
        message: '加载中...'
      })
      let e = this.item
      let url = '/main/shopDetails'
      return new Promise((resolve, reject) => {
        this.$Axios({ url: 'check_gift_rule', params: { amount: e.product_unit_price, user_rights_id: e.user_rights_id }, method: 'get' }).then((resp) => { // 请求成功
          if (resp.return_code === '0000') {
            // this.$toast(resp.data + ',可以购买')
            this.$router.push({ path: url,
              query: {
                pid: e.id,
                item_id: e.default_item_id,
                activity_id: e.activity_id ? e.activity_id : 0,
                activity_name: e.activity_name ? e.activity_name : ''
              }
            })
          } else {
            this.$parent.showTips(resp, e)
          }
          resolve(resp)
        }).catch((error) => { // 请求失败
          this.$_requestInterceptor('error', error)
          reject(error)
        })
      })
    }
  }
}
</script>

<style lang="css" scoped>
</style>
